home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -in_the_mag- / reader_requests / scilab / demos / velpic / snapshot.sci < prev    next >
Text File  |  1999-09-16  |  4KB  |  132 lines

  1. //[pk]=snapshot(pt,view,frames,pmode)
  2. //[pk]=snapshot(pt[,view][,frames][,pmode])
  3. //Plot sequence of matrices from a cube (representing snapshots) 
  4. //where the structure of the cube is represented by a matrix 
  5. //one big matrix of dimension mN x N, i.e.:
  6. //
  7. //                      | p1 |
  8. //                      | p2 |
  9. //                  pt= |  . |  and  pk is an NxN matrix
  10. //                      |  . |
  11. //                      | pm |
  12. //
  13. //
  14. //                   ___________
  15. //                  /|         /|                   view='top'
  16. //         p1 -----/ |        / |                
  17. //                /  |       /--------------------- first matrix 
  18. //               /_________ /   |                            |
  19. //               |   |     |    |-- first matrix             |
  20. //               |   |_____|____|             /              |
  21. //               |  /      |   /             /               V
  22. //         pm ---|-/       |  /-------------/------ last matrix
  23. //               |/        |-- last matrix /
  24. //               |_________|/  
  25. //                            view='front'
  26. //
  27. //
  28. // pt     :matrix of dimension mN x N
  29. // view   :character chain taking values 'top' or 'front'.
  30. //        :values of view are used as described in above figure.
  31. //        :default value of view is 'top'.
  32. // frames :frames is either of the form frames=fi:fstep:ff 
  33. //        :or frames=fstep (in which case frames=1:fstep:m) and 
  34. //        :indicates which subsequence of the collection of 
  35. //        :matrices is to be displayed. Default is frames=1:1:m.
  36. // pmode  :pmode='3d' for 3d plots and pmode='c' for contour plots
  37. //        :default is '3d'
  38. // pk     :last frame plotted by snapshot
  39. //
  40. //!
  41. //author: C. Bunks     date: 1-NOV-90
  42.  
  43.    [pr,pc]=size(pt);
  44.    kmax=pr/pc;
  45.    if ent(kmax)<>kmax then,
  46.       write(%io(2),'Give matrix column length:')
  47.       pc=read(%io(1),1,1);
  48.       kmax=pr/pc;
  49.    end,
  50.    write(%io(2),'Total Number of Frames: '+string(kmax)),
  51.  
  52. //default evaluation
  53.  
  54.    [lhs,rhs]=argn(0);
  55.    if rhs=1 then, view='top'; frames=1:kmax; pmode='3d'; end,
  56.    if rhs=2 then, 
  57.       if type(view)=10 then,
  58.          if view='top' then,
  59.             frames=1:kmax; pmode='3d';
  60.          else,
  61.             if view='front' then,
  62.                frames=1:kmax; pmode='3d';
  63.             else,
  64.                pmode=view; view='top'; frames1:kmax;
  65.             end,
  66.          end,
  67.       else, 
  68.          frames=view; view='top'; pmode='3d';
  69.          if maxi(size(frames))=1 then, 
  70.             if frames>0 then,
  71.                frames=1:frames:kmax; 
  72.             else,
  73.                frames=kmax:frames:1;
  74.             end,
  75.          end,
  76.       end,
  77.    end,
  78.    if rhs=3 then,
  79.       if type(view)=10 then,
  80.          if view='top' then,
  81.             if type(frames)=10 then
  82.                pmode=frames; frames=1:kmax;
  83.             else,
  84.                pmode='3d';
  85.             end,
  86.          else,
  87.             if view='front' then,
  88.                if type(frames)=10 then
  89.                   pmode=frames; frames=1:kmax;
  90.                else,
  91.                   pmode='3d';
  92.                end,
  93.             else,
  94.                pmode='3d';
  95.             end,
  96.          end,
  97.       else, 
  98.          pmode=frames; frames=view; view='top';
  99.          if maxi(size(frames))=1 then, 
  100.             if frames>0 then,
  101.                frames=1:frames:kmax; 
  102.             else,
  103.                frames=kmax:frames:1;
  104.             end,
  105.          end,
  106.       end,
  107.    end,
  108.    if maxi(size(frames))=1 then, 
  109.       if frames>0 then,
  110.          frames=1:frames:kmax; 
  111.       else,
  112.          frames=kmax:frames:1;
  113.       end,
  114.    end,
  115.  
  116. //plot 
  117.  
  118.    for k=frames,
  119.       if view='top' then,
  120.          pk=pt((k-1)*pc+1:k*pc,:);
  121.       else,
  122.          pk=pt(k:pc:pr,:);
  123.       end,
  124.       if pmode='3d' then,
  125.          plotdb(pk,'agc',[0,%pi/4],'x'),pause,xbasc();
  126.       else,
  127.          contour(1:pc,1:pc,pk,10),pause,xbasc();
  128.       end,
  129.    end,
  130.  
  131. //end
  132.